﻿<%@ Page Language="C#" MasterPageFile="~/Master.Master" AutoEventWireup="true" CodeBehind="DM_Mon.aspx.cs"
    Inherits="HoaDon.DM_Mon" Title="Danh mục món hoặc nguyên liệu" %>

<asp:Content ID="cthoadon" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <asp:ScriptManager runat="server">
    </asp:ScriptManager>
    <br />
    <asp:Label ID="lbban" runat="server" Font-Bold="True" Font-Size="14pt" ForeColor="#663300"
        Text="DANH MỤC MÓN HOẶC NGUYÊN LIỆU"></asp:Label>
    <br />
    <br />
    <asp:Label ID="lbkhu" runat="server" Text="Nhóm món, nguyên liệu"></asp:Label>
    <asp:DropDownList ID="drNhomMon" runat="server" Height="20px" Width="150px" OnSelectedIndexChanged="drNhomMon_SelectedIndexChanged"
        AutoPostBack="true">
    </asp:DropDownList>
    <br />
    <br />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server">
        <ContentTemplate>
            <asp:GridView ID="gdvban" runat="server" AutoGenerateColumns="False" AllowPaging="True"
                ShowFooter="True" OnPageIndexChanging="OnPaging" OnRowEditing="EditDM" OnRowUpdating="UpdateDM"
                OnSelectedIndexChanging="ViewTPDM" OnRowCancelingEdit="CancelEditDM">
                <AlternatingRowStyle BackColor="GradientActiveCaption" />
                <PagerStyle BackColor="WhiteSmoke" ForeColor="Black" HorizontalAlign="Center" />
                <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                <HeaderStyle BackColor="DodgerBlue" Font-Bold="True" ForeColor="White" />
                <EditRowStyle BackColor="#009933" />
                <Columns>
                    <asp:TemplateField HeaderText="Mã món (NL)">
                        <ItemTemplate>
                            <asp:Label ID="vtID" runat="server" Text='<%# Eval("vtID")%>'></asp:Label>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtvtID" runat="server"></asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Tên món (NL)">
                        <ItemTemplate>
                            <asp:Label ID="vtName" runat="server" Text='<%# Eval("vtName")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:TextBox ID="tbvtName" runat="server" Text='<%# Eval("vtName")%>'></asp:TextBox>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtvtName" runat="server"></asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Đvt">
                        <ItemTemplate>
                            <asp:Label ID="FK_DvtID" runat="server" Text='<%# Eval("FK_DvtID")%>'></asp:Label>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:DropDownList ID="drdvt" runat="server" DataSource='<%# getDataSource()%>' DataTextField="DvtName"
                                DataValueField="DvtID" SelectedValue='<%# Eval("FK_DvtID")%>'>
                            </asp:DropDownList>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:DropDownList ID="drfdvt" DataSource='<%# getDataSource()%>' DataTextField="DvtName"
                                DataValueField="DvtID" runat="server">
                            </asp:DropDownList>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Giá mua">
                        <ItemTemplate>
                            <div style="text-align: right;">
                                <asp:Label ID="Gia_Mua0" runat="server" Text='<%# Eval("Gia_Mua0", "{0:#,#}")%>'></asp:Label>
                            </div>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <div style="text-align: right;">
                                <asp:TextBox ID="tbGia_Mua0" runat="server" Text='<%# Eval("Gia_Mua0", "{0:#,#}")%>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtGia_Mua0" runat="server"></asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Giá bán">
                        <ItemTemplate>
                            <div style="text-align: right;">
                                <asp:Label ID="Gia_Ban0" runat="server" Text='<%# Eval("Gia_Ban0", "{0:#,#}")%>'></asp:Label>
                            </div>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <div style="text-align: right;">
                                <asp:TextBox ID="tbGia_Ban0" runat="server" Text='<%# Eval("Gia_Ban0", "{0:#,#}")%>'></asp:TextBox>
                            </div>
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:TextBox ID="txtGia_Ban0" runat="server"></asp:TextBox>
                        </FooterTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="NL">
                        <ItemTemplate>
                            <asp:CheckBox ID="NL" runat="server" Width="10px" Checked='<%# (Convert.ToBoolean(Eval("NL_yn")))%>'
                                Enabled="false"></asp:CheckBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:Button ID="btnEdit" runat="server" CommandArgument='<%# Eval("vtID")%>' Text="Sửa"
                                CommandName="Edit"></asp:Button>
                            <asp:Button ID="btnDedele" runat="server" CommandArgument='<%# Eval("vtID")%>' Text="Xóa"
                                OnClick="DeleteDM"></asp:Button>
                            <asp:Button ID="btView" runat="server" CommandArgument='<%# Eval("vtID")%>' Text="Xem"
                                CommandName="Select"></asp:Button>
                        </ItemTemplate>
                        <EditItemTemplate>
                            <asp:Button ID="btUpdate" runat="server" CommandArgument='<%# Eval("vtID")%>' Text="Đồng ý"
                                CommandName="Update" />
                            <asp:Button ID="btHuy" runat="server" CommandArgument='<%# Eval("vtID")%>' Text="Hủy"
                                CommandName="Cancel" />
                        </EditItemTemplate>
                        <FooterTemplate>
                            <asp:Button ID="btnAdd" runat="server" Text="Thêm" OnClick="AddNewDM" />
                        </FooterTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>
            <asp:Label ID="lbError" runat="server" ForeColor="Red"></asp:Label>
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="gdvban" />
            <asp:AsyncPostBackTrigger ControlID="drNhomMon" EventName="SelectedIndexChanged">
            </asp:AsyncPostBackTrigger>
            <asp:AsyncPostBackTrigger ControlID="drNhomMon" EventName="SelectedIndexChanged">
            </asp:AsyncPostBackTrigger>
        </Triggers>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="drNhomMon" EventName="SelectedIndexChanged" />
        </Triggers>
    </asp:UpdatePanel>
</asp:Content>
